from fastapi import APIRouter, Depends, Security
from fastapi.security import HTTPAuthorizationCredentials

from app.repository.auth_repo import JWTBearer, JWTRepo
from app.schema import ResponseSchema
from app.service.users import UserService

router = APIRouter(prefix="/users", tags=["user"], dependencies=[Depends(JWTBearer())])


@router.get("/", response_model=ResponseSchema, response_model_exclude_none=True)
async def get_user_profile(
        credentials: HTTPAuthorizationCredentials = Security(JWTBearer()),
):
    token = JWTRepo.extract_token(credentials)
    result = await UserService.get_user_profile(token["phone_number"])
    return ResponseSchema(detail="Successfully fetch data!", result=result)

# @router.post("/update-profile/")
# async def update_user_profile(credentials: HTTPAuthorizationCredentials = Security(JWTBearer())):

#     # await AuthService.update_profile_service(data)
#     return ResponseSchema(detail="Successfully update data!")
